import request from "@/utils/request";
import qs from "qs";
const {
  getSetting
} = window.systemParamsUtils;
const mp = getSetting('GATEWAY');

export function loginByUsername(username, password) {
    const data = {
        username,
        password
    };
    return request({
        url: "/login",
        method: "get",
        params: data,
        baseURL: mp
    });
}

export function logout(params) {
    return request({
        url: "/logout",
        method: "get",
        params,
        baseURL: mp
    });
}

export function getUserInfo(params) {
    return request({
        url: `/api/user/info`,
        method: "get",
        params,
        baseURL: mp
    });
}

export function getPermissions(token) {
    return request({
        url: "/user/permissions",
        method: "get",
        params: { token },
        baseURL: mp
    });
}

export function getOAuthTokeByCode(params) {
    return request({
        url: "/oauth/token",
        method: "post",
        data: qs.stringify(params),
        baseURL: mp
    });
}

// 获取用户信息 
export const getUserDetailInfo = () => {
  return request({
    url: `/v1/common/queryCurrenUserInfo`,
    method: 'get',
  });
}
